


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > trityp</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/highlight-idea.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.pack.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">&lt;empty package name&gt;</a>
</div>

<h1>Coverage Summary for Class: trityp (&lt;empty package name&gt;)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">trityp</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    40%
  </span>
  <span class="absValue">
    (2/5)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    57.4%
  </span>
  <span class="absValue">
    (27/47)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<div class="sourceCode" id="sourceCode"><i class="no-highlight">1</i>&nbsp;import java.io.*;
<i class="no-highlight">2</i>&nbsp;
<b class="nc"><i class="no-highlight">3</i>&nbsp;class trityp</b>
<i class="no-highlight">4</i>&nbsp;{
<b class="fc"><i class="no-highlight">5</i>&nbsp;    private static String[] triTypes = { &quot;&quot;, // Ignore 0.</b>
<i class="no-highlight">6</i>&nbsp;            &quot;scalene&quot;, &quot;isosceles&quot;, &quot;equilateral&quot;,
<i class="no-highlight">7</i>&nbsp;            &quot;not a valid triangle&quot;};
<b class="fc"><i class="no-highlight">8</i>&nbsp;    private static String instructions = &quot;This is the ancient &quot; +</b>
<i class="no-highlight">9</i>&nbsp;            &quot;TriTyp program.\nEnter three integers that represent the &quot; +
<i class="no-highlight">10</i>&nbsp;            &quot;lengths of the sides of a triangle.\nThe triangle will be &quot; +
<i class="no-highlight">11</i>&nbsp;            &quot;categorized as either scalene, isosceles, equilateral\n&quot; +
<i class="no-highlight">12</i>&nbsp;            &quot;or invalid.\n&quot;;
<i class="no-highlight">13</i>&nbsp;
<i class="no-highlight">14</i>&nbsp;
<i class="no-highlight">15</i>&nbsp;    public static void main (String[] argv)
<i class="no-highlight">16</i>&nbsp;    {  // Driver program for trityp
<i class="no-highlight">17</i>&nbsp;        int A, B, C;
<i class="no-highlight">18</i>&nbsp;        int T;
<i class="no-highlight">19</i>&nbsp;
<i class="no-highlight">20</i>&nbsp;//   if (argv.length == 3) {
<i class="no-highlight">21</i>&nbsp;//      A = Integer.parseInt(argv[0]);
<i class="no-highlight">22</i>&nbsp;//      B = Integer.parseInt(argv[1]);
<i class="no-highlight">23</i>&nbsp;//      C = Integer.parseInt(argv[2]);
<i class="no-highlight">24</i>&nbsp;//   } else {
<b class="nc"><i class="no-highlight">25</i>&nbsp;        System.out.println (instructions);</b>
<b class="nc"><i class="no-highlight">26</i>&nbsp;        System.out.println (&quot;Enter side 1: &quot;);</b>
<b class="nc"><i class="no-highlight">27</i>&nbsp;        A = getN();</b>
<b class="nc"><i class="no-highlight">28</i>&nbsp;        System.out.println (&quot;Enter side 2: &quot;);</b>
<b class="nc"><i class="no-highlight">29</i>&nbsp;        B = getN();</b>
<b class="nc"><i class="no-highlight">30</i>&nbsp;        System.out.println (&quot;Enter side 3: &quot;);</b>
<b class="nc"><i class="no-highlight">31</i>&nbsp;        C = getN();</b>
<b class="nc"><i class="no-highlight">32</i>&nbsp;        T = Triang (A, B, C);</b>
<i class="no-highlight">33</i>&nbsp;//   }
<i class="no-highlight">34</i>&nbsp;
<b class="nc"><i class="no-highlight">35</i>&nbsp;        System.out.println (&quot;Result is: &quot; + triTypes[T]);</b>
<i class="no-highlight">36</i>&nbsp;    }
<i class="no-highlight">37</i>&nbsp;
<i class="no-highlight">38</i>&nbsp;    // ====================================
<i class="no-highlight">39</i>&nbsp;// The main triangle classification method
<i class="no-highlight">40</i>&nbsp;    static int Triang (int Side1, int Side2, int Side3)
<i class="no-highlight">41</i>&nbsp;    {
<i class="no-highlight">42</i>&nbsp;        int triOut;
<i class="no-highlight">43</i>&nbsp;
<i class="no-highlight">44</i>&nbsp;        // triOut is output from the routine:
<i class="no-highlight">45</i>&nbsp;        //    Triang = 1 if triangle is scalene
<i class="no-highlight">46</i>&nbsp;        //    Triang = 2 if triangle is isosceles
<i class="no-highlight">47</i>&nbsp;        //    Triang = 3 if triangle is equilateral
<i class="no-highlight">48</i>&nbsp;        //    Triang = 4 if not a triangle
<i class="no-highlight">49</i>&nbsp;
<i class="no-highlight">50</i>&nbsp;        // After a quick confirmation that it&#39;s a legal
<i class="no-highlight">51</i>&nbsp;        // triangle, detect any sides of equal length
<b class="fc"><i class="no-highlight">52</i>&nbsp;        if (Side1 &lt;= 0 || Side2 &lt;= 0 || Side3 &lt;= 0)</b>
<i class="no-highlight">53</i>&nbsp;        {
<b class="fc"><i class="no-highlight">54</i>&nbsp;            triOut = 4;</b>
<b class="fc"><i class="no-highlight">55</i>&nbsp;            return (triOut);</b>
<i class="no-highlight">56</i>&nbsp;        }
<i class="no-highlight">57</i>&nbsp;
<b class="fc"><i class="no-highlight">58</i>&nbsp;        triOut = 0;</b>
<b class="fc"><i class="no-highlight">59</i>&nbsp;        if (Side1 == Side2)</b>
<b class="fc"><i class="no-highlight">60</i>&nbsp;            triOut = triOut + 1;</b>
<b class="fc"><i class="no-highlight">61</i>&nbsp;        if (Side1 == Side3)</b>
<b class="fc"><i class="no-highlight">62</i>&nbsp;            triOut = triOut + 2;</b>
<b class="fc"><i class="no-highlight">63</i>&nbsp;        if (Side2 == Side3)</b>
<b class="fc"><i class="no-highlight">64</i>&nbsp;            triOut = triOut + 3;</b>
<b class="fc"><i class="no-highlight">65</i>&nbsp;        if (triOut == 0)</b>
<i class="no-highlight">66</i>&nbsp;        {  // Confirm it&#39;s a legal triangle before declaring
<i class="no-highlight">67</i>&nbsp;            // it to be scalene
<i class="no-highlight">68</i>&nbsp;
<b class="fc"><i class="no-highlight">69</i>&nbsp;            if (Side1+Side2 &lt;= Side3 || Side2+Side3 &lt;= Side1 || Side1+Side3 &lt;= Side2)</b>
<b class="fc"><i class="no-highlight">70</i>&nbsp;                triOut = 4;</b>
<i class="no-highlight">71</i>&nbsp;            else
<b class="fc"><i class="no-highlight">72</i>&nbsp;                triOut = 1;</b>
<b class="fc"><i class="no-highlight">73</i>&nbsp;            return (triOut);</b>
<i class="no-highlight">74</i>&nbsp;        }
<i class="no-highlight">75</i>&nbsp;
<i class="no-highlight">76</i>&nbsp;        /* Confirm it&#39;s a legal triangle before declaring  */
<i class="no-highlight">77</i>&nbsp;        /* it to be isosceles or equilateral  */
<i class="no-highlight">78</i>&nbsp;
<b class="fc"><i class="no-highlight">79</i>&nbsp;        if (triOut &gt; 3)</b>
<b class="fc"><i class="no-highlight">80</i>&nbsp;            triOut = 3;</b>
<b class="fc"><i class="no-highlight">81</i>&nbsp;        else if (triOut == 1 &amp;&amp; Side1+Side2 &gt; Side3)</b>
<b class="fc"><i class="no-highlight">82</i>&nbsp;            triOut = 2;</b>
<b class="fc"><i class="no-highlight">83</i>&nbsp;        else if (triOut == 2 &amp;&amp; Side1+Side3 &gt; Side2)</b>
<b class="fc"><i class="no-highlight">84</i>&nbsp;            triOut = 2;</b>
<b class="fc"><i class="no-highlight">85</i>&nbsp;        else if (triOut == 3 &amp;&amp; Side2+Side3 &gt; Side1)</b>
<b class="fc"><i class="no-highlight">86</i>&nbsp;            triOut = 2;</b>
<i class="no-highlight">87</i>&nbsp;        else
<b class="fc"><i class="no-highlight">88</i>&nbsp;            triOut = 4;</b>
<b class="fc"><i class="no-highlight">89</i>&nbsp;        return (triOut);</b>
<i class="no-highlight">90</i>&nbsp;    } // end Triang
<i class="no-highlight">91</i>&nbsp;
<i class="no-highlight">92</i>&nbsp;    // ====================================
<i class="no-highlight">93</i>&nbsp;// Read (or choose) an integer
<i class="no-highlight">94</i>&nbsp;    private static int getN ()
<i class="no-highlight">95</i>&nbsp;    {
<b class="nc"><i class="no-highlight">96</i>&nbsp;        int inputInt = 1;</b>
<b class="nc"><i class="no-highlight">97</i>&nbsp;        BufferedReader in = new BufferedReader (new InputStreamReader (System.in));</b>
<i class="no-highlight">98</i>&nbsp;        String inStr;
<i class="no-highlight">99</i>&nbsp;
<i class="no-highlight">100</i>&nbsp;        try
<i class="no-highlight">101</i>&nbsp;        {
<b class="nc"><i class="no-highlight">102</i>&nbsp;            inStr = in.readLine ();</b>
<b class="nc"><i class="no-highlight">103</i>&nbsp;            inputInt = Integer.parseInt(inStr);</b>
<i class="no-highlight">104</i>&nbsp;        }
<b class="nc"><i class="no-highlight">105</i>&nbsp;        catch (IOException e)</b>
<i class="no-highlight">106</i>&nbsp;        {  // JDK requires the IOException to be caught.
<b class="nc"><i class="no-highlight">107</i>&nbsp;            System.out.println (&quot;Could not read input, choosing 1.&quot;);</b>
<i class="no-highlight">108</i>&nbsp;        }
<b class="nc"><i class="no-highlight">109</i>&nbsp;        catch (NumberFormatException e)</b>
<i class="no-highlight">110</i>&nbsp;        {
<b class="nc"><i class="no-highlight">111</i>&nbsp;            System.out.println (&quot;Entry must be a number, choosing 1.&quot;);</b>
<b class="nc"><i class="no-highlight">112</i>&nbsp;        }</b>
<i class="no-highlight">113</i>&nbsp;
<b class="nc"><i class="no-highlight">114</i>&nbsp;        return (inputInt);</b>
<i class="no-highlight">115</i>&nbsp;    } // end getN
<i class="no-highlight">116</i>&nbsp;
<i class="no-highlight">117</i>&nbsp;} // end trityp class
</div>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
        var codeBlock = document.getElementById('sourceCode');

        if (codeBlock) {
            hljs.highlightBlock(codeBlock);
        }
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2022-04-30 17:31</div>
</div>
</body>
</html>
